package com.wiim.handler;

import java.io.Serializable;

import com.wiim.model.UserData;
import com.wiim.nhapnhap.EgoodApp;
import com.wiim.processor.CMProcessor;

import android.os.Bundle;

public class CMCmdHandler extends BaseCmdHandler {

	public final static int COMMAND_INIT_APP = 900;
	public final static int COMMAND_LOGIN_VALIDATE = 301;
	public final static int COMMAND_HELLO = 302;

	@Override
	public Bundle commandHandler(int command, Bundle cmdData) {
		CMProcessor connector = new CMProcessor();

		Bundle resultData = new Bundle();

		Object result = null;

		switch (command) {

		case COMMAND_INIT_APP:
			break;

		case COMMAND_LOGIN_VALIDATE: {
			UserData uData = (UserData)cmdData.getSerializable(EgoodApp.REST_OBJECT_PUT);		
			result = connector.LoginValidate(uData);
			resultData.putSerializable(EgoodApp.REST_OBJECT_RETURN, (Serializable) result);
		}
			break;
			
		case COMMAND_HELLO: {				
			result = connector.getHelloWorld();
			resultData.putSerializable(EgoodApp.REST_OBJECT_RETURN, (String) result);
		}
			break;

		default:
			break;
		}

		return resultData;
	}
}
